//
//  HYGrowingUpFilesPictures.m
//  child
//
//  Created by lijianguomac on 13-10-2.
//  Copyright (c) 2013年 lijianguomac. All rights reserved.
//

#import "HYGrowingUpFilesPictures.h"
#import "HYGrowingUpFilesPicturesCell.h"
#import "HYSendPicturesAndText.h"

@interface HYGrowingUpFilesPictures (){
    NSMutableArray *datas;
}

@end

@implementation HYGrowingUpFilesPictures

@synthesize growingUpFilesPicturesCellNib;

- (void)dealloc{
    [super dealloc];
    [growingUpFilesPicturesCellNib release];
    [datas release];
}


-(UINib*)statusCellNib
{
    if (growingUpFilesPicturesCellNib == nil)
    {
        [growingUpFilesPicturesCellNib release];
        growingUpFilesPicturesCellNib = [[HYGrowingUpFilesPicturesCell nib] retain];
    }
    return growingUpFilesPicturesCellNib;
}

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        [self myInit];
    }
    return self;
}

- (void)myInit{
//    self.navigationItem.title = self.navTitle;
    UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 80, 30)];
//    [btn set]
    UIImage *img = [[UIImage imageNamed:@"btn_header_r.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:5.0];
    [btn setBackgroundImage:img forState:UIControlStateNormal];
    [btn setTitle:@"上传图片" forState:UIControlStateNormal];
    btn.titleLabel.shadowColor = [UIColor colorWithRed:0.855 green:0.863 blue:0.882 alpha:1.0];
    //    btn.titleLabel.textColor = [UIColor colorWithRed:0.298 green:0.337 blue:0.424 alpha:1.0];
    //
    //    [btn addTarget:self action:@selector(btnSender:) forControlEvents:UIControlEventTouchDown];
    
    //    UIButton *btnRight = [UIButton buttonWithType:UIButtonTypeCustom];
    //    btnRight.frame = CGRectMake(0, 0, 30, 30);
    //    btnRight.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    //    btnRight.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    //    [btnRight setBackgroundImage:[UIImage imageNamed:@"submit"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(goUpload) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *bbiRight = [[UIBarButtonItem alloc] initWithCustomView:btn];
    [btn release];
    self.navigationItem.rightBarButtonItem = bbiRight;
    [bbiRight release];
    datas = [[NSMutableArray alloc] initWithCapacity:0];
    [datas addObject:@"http://c.hiphotos.baidu.com/album/w%3D2048/sign=bfa8ac5a03087bf47dec50e9c6eb562c/6a63f6246b600c3325794dd91b4c510fd9f9a19b.jpg"];
    
    [datas addObject:@"http://e.hiphotos.baidu.com/album/w%3D2048/sign=1edf8551738b4710ce2ffaccf7f6c2fd/c995d143ad4bd113d78eca425bafa40f4bfb057a.jpg"];
    
    [datas addObject:@"http://b.hiphotos.baidu.com/album/w%3D2048/sign=1a560359f31fbe091c5ec4145f580d33/64380cd7912397ddc0d9a42b5882b2b7d0a28778.jpg"];
    [self tableView].separatorStyle = NO;
    self.tableView.showsVerticalScrollIndicator = NO;
}

- (void)goUpload{
    HYSendPicturesAndText *sendPicturesAndText = [[HYSendPicturesAndText alloc] initWithStyle:UITableViewStylePlain];
    [self.navigationController pushViewController:sendPicturesAndText animated:YES];
    [sendPicturesAndText release];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
    if ( IOS7_OR_LATER )
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
        
    }
#endif
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
 
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int num = 0;
    if(section==0){
        num=6;
    }else if(section==1){
        num=6;
        
    }else if(section==2){
        num=6;
        
    }
    
    return num;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    int height = 0;
    if(indexPath.row==0||indexPath.row==3){
        height = 30;
    }else{
        height = 100;
    }
    
    return height;
}

//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
//{
//    return 40;
//}
//- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
//    
//    
//    
//    return  @"9月17日";
//}
- (id)cellForTableView:(UITableView *)tableView fromNib:(UINib *)nib {
    static NSString *cellID = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        NSArray *nibObjects = [nib instantiateWithOwner:nil options:nil];
        cell = [nibObjects objectAtIndex:0];
    }
    else {
        [(ETBaseCell *)cell reset];
    }
    
    return cell;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HYGrowingUpFilesPicturesCell *cell = [self cellForTableView:tableView fromNib:[self statusCellNib]];
    
    if(indexPath.row==0){
        [cell setView:YES datas:datas];
    }else if(indexPath.row==3){
        [cell setView:YES datas:datas];
    }else{
        [cell setView:NO datas:datas];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a story board-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}

 */

@end
